<?php 

include 'includes/classes/core.php';

if($_REQUEST['act'] == 'get_checker'){
	
	
	$user_id	= $_SESSION['USERID'];
	
	$res = mysql_fetch_assoc(mysql_query("
										SELECT crystal_users.group_id
										FROM    crystal_users
										WHERE  crystal_users.id = $user_id
			"));
		$group = $res['group_id'];
		
	
	
	
	 
    
    if($group == 3){
    	
        $check_count = '';
        $check_count1 = '';
        
    }else{
        $check_count = "AND task.responsible_user_id1 = '$user_id'";
        $check_count1 = "AND task.responsible_user_id='$user_id'";
    }
    $task_now_count1 = mysql_fetch_row(mysql_query(" SELECT COUNT(*)
											        		FROM `task`
											        		WHERE (task.`status` = 2 or task.`status`=0 ) AND `task_type_id`=1 $check_count1"));
   
    
   $task_now_count = mysql_fetch_row(mysql_query(" SELECT COUNT(*)
                                                    FROM `task`
                                                    WHERE task.`status` = 0 $check_count1"));
    
    $action_now_count = mysql_fetch_row(mysql_query("   SELECT COUNT(*)
	                                                    FROM `task`
	                                                    WHERE task.`status` = 1 AND `task_type_id`=1 $check_count"));
    $count = "";
    
    if($task_now_count1[0] > 0){
    	
    	
    	$count .= "<div id=\"news_s\"><span>თქვენ გაქვთ $task_now_count1[0] ახალი  გამავალი ზარი პირველადში</span></div>";
    
    }
    
    if($task_now_count[0] > 0){
        
            $count .= "<div id=\"news\"><span>თქვენ გაქვთ $task_now_count[0] ახალი დავალება</span></div>";
        
    }
    
    if($action_now_count[0] > 0){
       
            $count .= "<div id=\"news_action\"><span>თქვენ გაქვთ $action_now_count[0] ახალი გამავალი ზარი მიმდინარეში</span></div>";
        
    }
    
    $data = array('count'=>$count);
    
    echo json_encode($data);
}

?>